package test.crane;

import ptolemy.actor.*;
import ptolemy.kernel.*;
import ptolemy.kernel.util.*;
import ptolemy.data.*;
import ptolemy.data.type.*;

//////////////////////////////////////////////////////////////////////////
//// IsKnown
/**

@author Ivan Jeukens
@version v 0.1 07/02/2002
*/
public class IsKnown extends TypedAtomicActor {

    public IsKnown(CompositeEntity container, String name) throws
            IllegalActionException, NameDuplicationException {
        super(container, name);

        input = new TypedIOPort(this, "input", true, false);
        input.setTypeEquals(BaseType.GENERAL);

        output = new TypedIOPort(this, "output", false, true);
        output.setTypeEquals(BaseType.BOOLEAN);
    }

    public TypedIOPort input;
    public TypedIOPort output;

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    public void fire() throws IllegalActionException {
        if(input.isKnown()) {
            if(input.hasToken(0)) {
                output.broadcast(new BooleanToken(true));
            }
        }

        if(input.isKnown() && !output.isKnown()) {
            output.broadcastClear();
        }
    }

    ///////////////////////////////////////////////////////////////////
    ////                        private methods                    ////

    ///////////////////////////////////////////////////////////////////
    ////                      private variables                    ////

}
